﻿Imports System.Data.Entity.Validation
Imports System
Imports System.Security.Claims
Imports System.Web.UI
Imports System.Data.OleDb



Public Class Register
    Inherits System.Web.UI.Page




    Protected Sub CreateUser(sender As Object, e As EventArgs)

        Dim userName_1 As String = UserName.Text

        Dim outputstatus As String = ""


        Dim iReturnValue As Integer
        iReturnValue = MsgBox("Accept Cookies?", vbYesNo + vbQuestion)
        If iReturnValue = vbYes Then
            'Continue next step
            outputstatus = "YES"
        Else
            'Stop
            outputstatus = ""
        End If

        ' New Code - Register.aspx.vb - 12 Jan 2014 - Gene Da Rocha - Add Cookie smscookie to the system for username and Email format checker in javascript on the .aspx file. Also a redirection to login.aspx
        If outputstatus = "YES" Then
            Response.Cookies("smscookie")("Data") = userName_1
            Response.Cookies("smscookie")("Time") = DateTime.Now.AddDays(1)
        End If

        Try

            ' New Code - Register.aspx.vb - 03 Jan 2014 - Gene Da Rocha - Add the insertion of "Standard User" to the system

            Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString004").ConnectionString)
            Dim SqlString As String = "Insert into sms_register(username, sms_usertype_fkid, emailaddress, thepassword) Values (@f1,@f2,@f3,@f4)"

            Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)


            theusername.Text = userName_1
            thereference.Text = "1"

            cmd.CommandType = CommandType.Text
            cmd.Parameters.AddWithValue("@f1", theusername.Text)
            cmd.Parameters.AddWithValue("@f2", thereference.Text)
            cmd.Parameters.AddWithValue("@f3", theemailaddress.Text)
            cmd.Parameters.AddWithValue("@f4", Password.Text)
            oleDbConn.Open()
            cmd.ExecuteNonQuery()

            Response.Redirect("login.aspx")
        Catch ex As DbEntityValidationException
            ErrorMessage.Text = ex.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage
        End Try


    End Sub


    Private Sub RedirectToReturnUrl(p1 As String)
        Throw New NotImplementedException
    End Sub




    Private Function MsgBoxStyle() As MsgBoxStyle
        Throw New NotImplementedException
    End Function

    Protected Sub UserName_TextChanged(sender As Object, e As EventArgs) Handles UserName.TextChanged

    End Sub

    Private Function DialogResult() As Object
        Throw New NotImplementedException
    End Function

    Private Function MessageBoxButtons() As Object
        Throw New NotImplementedException
    End Function

    Private Function MessageBox() As Object
        Throw New NotImplementedException
    End Function



End Class